﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace FirmaTransportowa
{
    public partial class DriverBeginTransportForm : Form
    {
        private DriverPanelPresenter presenter;

        public DriverBeginTransportForm(DriverPanelPresenter presenter)
        {
            InitializeComponent();
            this.presenter = presenter;
        }

        public void showDataTable()
        {
            transportsGridView.Columns[0].HeaderText = "ID";
            transportsGridView.Columns[1].HeaderText = "Status";
            transportsGridView.Columns[2].HeaderText = "Data transportu";
            transportsGridView.Columns[3].HeaderText = "Czas rozpoczęcia";
            transportsGridView.Columns[4].HeaderText = "Czas zakończenia";
            transportsGridView.Columns[5].HeaderText = "Miejscowość startowa";
            transportsGridView.Columns[6].HeaderText = "Miejscowość docelowa";
            transportsGridView.Columns[7].HeaderText = "Odległość[km]";
            transportsGridView.Columns[8].HeaderText = "Marka pojazdu";
            transportsGridView.Columns[9].HeaderText = "Model pojazdu";
            transportsGridView.Columns[10].HeaderText = "Ładowność";
            transportsGridView.Columns[11].HeaderText = "Imię dyspozytora";
            transportsGridView.Columns[12].HeaderText = "Nazwisko dyspozytora";
            transportsGridView.Columns[13].HeaderText = "Imię kierowcy";
            transportsGridView.Columns[14].HeaderText = "Nazwisko kierowcy";
            transportsGridView.Columns[0].Width = 100;
            transportsGridView.Columns[1].Width = 100;
            transportsGridView.Columns[2].Width = 65;
            transportsGridView.Columns[3].Width = 80;
            transportsGridView.Columns[4].Width = 80;
            transportsGridView.Columns[5].Width = 140;
            transportsGridView.Columns[6].Width = 140;
            transportsGridView.Columns[7].Width = 100;
            transportsGridView.Columns[8].Width = 120;
            transportsGridView.Columns[9].Width = 120;
            transportsGridView.Columns[10].Width = 80;
            transportsGridView.Columns[11].Width = 100;
            transportsGridView.Columns[12].Width = 100;
            transportsGridView.Columns[13].Width = 100;
            transportsGridView.Columns[14].Width = 100;
        }

        private void startTransport_Click(object sender, EventArgs e)
        {
            if (transportsGridView.SelectedRows.Count > 1) {
                MessageBox.Show("Zaznacz tylko jeden transport!");
            } else if (transportsGridView.SelectedRows.Count == 1) {
                presenter.startTransport();
            }
        }

        private void DriverBeginTransportForm_HelpButtonClicked(object sender, CancelEventArgs e)
        {
            HelpUtils.showHelp(this, 7);
        }

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == Keys.F1)
            {
                HelpUtils.showHelp(this, 7);
                return true;
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }
    }
}